<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /**
         * Cookie
         */ 
        document.cookie = "username=tom"

        var date = new Date()
        date.setDate(date.getDate()+7)
        document.cookie = "age=20; expires=" + date.toUTCString()

        // 获取cookie
        console.log(document.cookie)


        /**
         * WebStorage
         */ 
        localStorage.setItem('name', '张三')
        console.log(localStorage.getItem('name'))


        var stu = {
            "id": 1001,
            "name":"tom",
            "age":19
        }
        sessionStorage.setItem("stu", JSON.stringify(stu))

        var obj = JSON.parse(sessionStorage.getItem('stu'))
        console.log(obj)

        localStorage.removeItem('name')
    </script>
</head>
<body>
    
</body>
</html>